<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //扩展内置对象的方法
        console.log(Array.prototype);
        Array.prototype.sum = function(){
            var sum = 0;
             for(var i = 0; i < this.length; i++){
                sum += this[i];
             }
             return sum;
        }
        Array.prototype = {
            /* 不能以对象的形式追加自定义函数 */
        }
        var arr = [1,2,3,4];
        /* console.log(Array.prototype); */
        console.log(arr.sum());
    </script>
</body>
</html>